feat: create table UserPracticeAreaSecondaryXref (#680)#687
Conversation
fyliu
left a comment
There was a problem hiding this comment.
Thanks for getting this done so quickly and the great clarification questions!
Now that I'm reading the changes, I realized my last comment in slack about calling it practice_areas_secondary was confusing. I meant you should name the User model field practice_areas_secondary. You were correct before to name the relate_name "users_secondary". Can you change it back? Thanks!
…API, migrations, and DBML schema
fyliu
left a comment
There was a problem hiding this comment.
Thanks!
Looks like there's a test failure. Maybe the it needed updating.
Details
django.db.utils.IntegrityError: duplicate key value violates unique constraint "uniq_global_user_check"
DETAIL: Key (user_id, check_type_id)=(7ed5ee45-9d34-4091-bb8e-8cba1e28f02f, ed02c501-12cc-44b4-bf6c-40c846a5d9c1) already exists.
=========================== short test summary info ============================
FAILED core/tests/test_api.py::test_api_prevent_duplicate_global_usercheck - ...
!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!! xdist.dsession.Interrupted: stopping after 1 failures !!!!!!!!!!!!!
======================== 1 failed, 42 passed in 21.59s =========================
|
Nevermind the above comment. I ran update-requirements locally, and the newer version is what broke the test. |
There was a problem hiding this comment.
-
Models: Implemented UserPracticeAreaSecondaryXref model to serve as a custom through-table, adding full_clean() validation to act as a database-level failsafe against duplicate primary/secondary practice area assignments.
-
Admin: Refined the ValidationError copy in admin.py to provide clear, actionable feedback to staff if they attempt to save conflicting data.
-
Naming Conventions: Updated the User model fields and related names to practice_areas_secondary and users_secondary per previous review feedback.
-
Verification: All automated tests are passing, and the integrity of the data is now protected at both the form and model layers
I went in to double check my code didn't break anything and realized a validation check in my model couldn't hurt the database
Fixes #680
What changes did you make?
UserPracticeAreaSecondaryXrefmodel to serve as the customthroughtable for thepractice_area_secondarymany-to-many relationship.UserSerializerto support the new secondary practice area structure. Overrode the Django update method to sanitize the incoming payload, silently discarding duplicate primary/secondary assignments before saving.test_models.pyassertions to align with the implementedpractice_areas_secondaryreverse relation.scripts/validate_mkdocs.shto use modern Docker compose syntax.Why did you make the changes (we will use this info to test)?
UserPracticeAreaSecondaryXrefmodel to setup the necessary backend table that joins a user with multiple practice areasScreenshots of Proposed Changes To The Website
Django Admin Validation- Demonstrates custom validation preventing duplicate primary/secondary selections in the Django Admin interface.
API Form View - Verifies the DRF browsable API correctly renders the secondary practice area as a multi-select field.
API JSON Response - Confirms the DRF serializer successfully returns a `200 OK` and correctlyexposes the new many-to-many relationship as a list.*